//
// Created by liushuai on 2021/3/10.
//

#include "permute.h"
void permute(vector<int>& nums,vector<vector<int> >&cache,int start){
    if(start==nums.size()){
        cache.push_back(nums);
    }else{
        for(int i=start;i<nums.size();i++){
            std::swap(nums[start],nums[i]);
            permute(nums,cache,start+1);
            std::swap(nums[start],nums[i]);
        }
    }

}
vector<vector<int>> permute(vector<int>& nums){
    vector<vector<int>>res;
    if(nums.empty())
        return res;
    else
        permute(nums,res,0);
    return res;
}